package encome.work.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import encome.work.dao.Car;
import encome.work.mapper.CarMapper;
import encome.work.service.CarService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

@Service
public class CarServiceImpl extends ServiceImpl<CarMapper,Car> implements CarService {
    @Resource
    CarMapper carMapper;
    @Override
    public void add(Car car) {
        carMapper.insert(car);
    }

    @Override
    public void update(Car car) {
        carMapper.updateById(car);
    }

    @Override
    public void delete(Long id) {
        carMapper.deleteById(id);
    }

    @Override
    public Page<Car> findPage(Car car, Integer page, Integer pageSize) {
        Page<Car> pageInfo = new Page<>(page, pageSize);
        LambdaQueryWrapper<Car> queryWrapper = new LambdaQueryWrapper<>();
        return carMapper.selectPage(pageInfo, queryWrapper);
    }

    @Override
    public Car findById(Long id) {
        return carMapper.selectById(id);
    }

    @Override
    public Page<Car> findPage(Integer page, Integer pageSize) {
        Page<Car> pageInfo = new Page<>(page, pageSize);
        LambdaQueryWrapper<Car> queryWrapper = new LambdaQueryWrapper<>();
        return carMapper.selectPage(pageInfo,queryWrapper);
    }
}
